package tsb.dominio.interfaces;

import java.net.UnknownHostException;
/**
 * @author Federico Gomez
 * @version 1.0
 * @created 16-Mar-2011 12:00:27 a.m.
 */
public class IP {

	private String IP;

	public IP(){

	}

    public IP(String IP) {
        this.IP = IP;
    }

    public String getIP() {
        return IP;
    }

    public void setIP(String IP) {
        this.IP = IP;
    }
    
  
    public static boolean comprobrarIP(String ip)
    {
        String ip2=ip.trim();
        char b= ip2.charAt(ip2.length()-1);
        if(b=='.')
            return false;
        
        String[] a=ip2.split("\\.");
        
        if(a.length!=4)
            return false;
        
        for(int i=0; i<a.length;i++)
        {
            int c=0;
            try{
                 c=Integer.parseInt(a[i]);
            }
            catch(java.lang.NumberFormatException e){
               return false;
            }
            
            if(!(c>0 && c<256))
               return false;
        }
        return true;
    }
    
    public String toString()
    {
        return this.IP;
    }

	

}